<?php

class controller_product extends controller_theme
{

	public function __construct()
	{
		parent::__construct();
	}


	// 业务范围
	public function listing()
	{
		$model = bone::get_model('product');
		$products = $model->get_products();
		$categories = $model->get_categories();

		$template = bone::get_template('product.listing');
		$template->set_title('业务范围');
		$template->set('products', $products);
		$template->set('categories', $categories);
		$template->set_data($this->get_data());
		$template->display();
	}


	// 业务详情
	public function detail()
	{
		$product_id = get('product_id', 0, 'int');
		if(!$product_id) exit('变量{product_id}缺失');


		$product = bone::get_table('product');
		$product->load($product_id);
		$product->hit();

		$product_category = bone::get_table('product_category');
		$product_category->load($product->category_id);

		$template = bone::get_template('product.detail');
		$template->set_title($product->name);
		$template->set_meta_keyword( $product->meta_keywords );
		$template->set_meta_description( $product->meta_description );
		$template->set('product', $product);
		$template->set('product_category', $product_category);
		$template->set_data($this->get_data());
		$template->display();
	}


}
?>